package cn.itcast.servlet;

import cn.itcast.domain.Student;
import cn.itcast.utils.DataSourceUtil;
import com.alibaba.druid.pool.DruidDataSource;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class Demo_Duid {
    public static void main(String[] args)  throws Exception{
        List<Student> lis = new ArrayList<Student>();
        DruidDataSource ds = new DruidDataSource();


        //获取连接ds
        Connection conn = DataSourceUtil.getConn();
        String sql = "select * from student";
        PreparedStatement ps = conn.prepareStatement(sql);

        ResultSet rs = ps.executeQuery();

        while (rs.next()){
            Student stu = new Student(rs.getInt(1),rs.getString(2),rs.getInt(3),rs.getDate(4));
            lis.add(stu);
        }
        DataSourceUtil.close(conn,ps,rs);
        System.out.println(lis+"111111");
    }



}
